package com.tiny.work.tiny_task;

import org.apache.commons.mail.EmailException;

public class EmailSendServiceImpl implements EmailSendService{

    @Override
    public void send(EmailMessage emailMessage) throws EmailException {

    }
//
//    private EmailConfig emailConfig;
//    private Authenticator authenticator;
//
//
//    public EmailSendServiceImpl(){
//        emailConfig = EmailConfig.getInstance();
//        authenticator = new DefaultAuthenticator(emailConfig.getUserName(), emailConfig.getPassword());
//    }
//
//    @Override
//    public void send(EmailMessage emailMessage) throws EmailException {
//        HtmlEmail result = initHtmlEmail();
//        result.setSubject(emailMessage.getTitle());
//        result.setFrom(emailConfig.getUserName());
//        result.setHtmlMsg(emailMessage.getBody());
//        for (String to : emailMessage.getToList()) {
//            result.addTo(to);
//        }
//        result.send();
//    }
//
//    private HtmlEmail initHtmlEmail() throws EmailException {
//        HtmlEmail result = new HtmlEmail();
//        Properties prop = new Properties();
//        // 设置SMTP发送服务器的名字：163的如下："smtp.163.com"
//        prop.setProperty("mail.smtp.host", emailConfig.getHost());
//        // 设置SMTP发送服务器的端口
//        prop.setProperty("mail.smtp.port", emailConfig.getPort());
//        // 设置是否需要认证
//        prop.setProperty("mail.smtp.auth", "true");
//        // 开启TLS加密方式
//        prop.setProperty("mail.smtp.starttls.enable", "true");
//        prop.setProperty("mail.smtp.ssl.trust", emailConfig.getHost());
//
//        Session session = Session.getInstance(prop,authenticator);
//
//        result.setMailSession(session);
//
////        result.setSSL(true);
////        result.setSslSmtpPort(emailConfig.getPort());
////        result.setHostName(emailConfig.getHost());
////        result.setAuthenticator(authenticator);
////        result.setSmtpPort(Integer.parseInt(emailConfig.getPort()));
//
//        result.setCharset(emailConfig.getCharSet());
//        return result;
//    }
}
